package cn.caipengbo.ajax;

import com.opensymphony.xwork2.Action;
import net.sf.json.JSONObject;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Myth on 2/12/2017.
 */
public class AjaxAction implements Action {
    private JSONObject jsonresult;
    public JSONObject getJsonresult() {
        return jsonresult;
    }
    public void setJsonresult(JSONObject jsonresult) {
        this.jsonresult = jsonresult;
    }
    public String doPrint() throws Exception {
        System.out.println("action execute");
        List list = new ArrayList<>();
        Map<String,Object> map = new HashMap<String,Object>();
        Map<String,Object> map2 = new HashMap<String,Object>();
        map.put("name","myth");
        map.put("phone","123456");
        map2.put("name","myth2");
        map2.put("phone","654321");
        list.add(map);
        list.add(map2);
        Map<String,Object> jsontemp = new HashMap<String,Object>();
        jsontemp.put("total",list.size());
        jsontemp.put("rows", list);
        jsonresult = JSONObject.fromObject(jsontemp);
        System.out.println(jsonresult);
        return SUCCESS;
    }
    @Override
    public String execute() throws Exception {
        return null;
    }


}
